<?php
namespace App\Http\Requests\Eticket;
use Illuminate\Foundation\Http\FormRequest;
class ActivityRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        $rules['name'] = 'required';
        $rules['school'] = 'required';
        $rules['start_date'] = 'required';
        $rules['end_date'] = 'required';
        $rules['location'] = 'required';
        if (request()->isMethod('PUT') || request()->isMethod('PATCH')) {
            // 修改时 request()->method() 方法返回的是 PUT或PATCH
            $rules['id'] = 'numeric|required';
        }
        return $rules;
    }
    /**
     * 验证信息
     * @author 晚黎
     * @date   2016-11-02T10:25:59+0800
     * @return [type]                   [description]
     */
    public function messages()
    {
        return [
            'required'  => trans('validation.required'),
            'numeric'   => trans('validation.numeric'),
        ];
    }
    /**
     * 字段名称
     * @author 晚黎
     * @date   2016-11-02T10:28:52+0800
     * @return [type]                   [description]
     */
    public function attributes()
    {
        return [
            'id'    => trans('act/ticket.model.id'),
            'name'  => trans('act/ticket.model.name'),
            'start_date'  => trans('act/ticket.model.start_date'),
            'end_date'  => trans('act/ticket.model.end_date'),
            'location'  => trans('act/ticket.model.location'),
            'school'  => trans('act/ticket.model.school'),
        ];
    }
}
